﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using ZDSoft.TES.Entity.FunctionEntity;

namespace ZDSoft.TES.Entity.SystemEntity
{
    [ActiveRecord("SystemUser")]
    public class User : EntityBase<User>
    {
        /// <summary>
        /// 帐号
        /// </summary>
        [Property]
        public string Account { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Property]
        public string Password { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [Property]
        public string UserName { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Property]
        public bool IsActive { get; set; }

        /// <summary>
        /// 用户是否提交重置密码
        /// </summary>
        public bool IsReset { get; set; }

        [HasAndBelongsToMany(typeof(Role), Table = "SystemUserRole", ColumnKey = "UserID", ColumnRef = "RoleID" , Lazy = true)]
        public IList<Role> Roles { get; set; }

        [BelongsTo("OrganizationID", Lazy = FetchWhen.OnInvoke)]
        public Organization Organization { get; set; }

        [HasMany(typeof(UserCourse), ColumnKey = "UserID", Inverse = true, Lazy = true)]
        public IList<UserCourse> UserCourses { get; set; }

        [HasMany(typeof(Score), ColumnKey = "UserID", Inverse = true, Lazy = true)]
        public IList<Score> Scores { get; set; }
    }
}
